import { AbstractSelectConfig } from 'babylon-lib/pick/selector/config/abstract-select-config';
import { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';
import { Helper } from 'babylon-lib/tool/helper';
import { AbstractCommunity } from '../community/abstract-community';


class CommunitySelectConfig extends AbstractSelectConfig<AbstractCommunity> {

    public test(target: AbstractCommunity): boolean {
        return target instanceof AbstractCommunity;
    }

    public compare(a: AbstractCommunity, b: AbstractCommunity): boolean {
        return a.id === b.id;
    }

    public meshes(target: AbstractCommunity): AbstractMesh[] {
        return [target.pickMesh];
    }

    public isMeshOfTarget(mesh: AbstractMesh, target: AbstractCommunity): number {
        return Helper.isChild(mesh, target.container);
    }

}


export { CommunitySelectConfig };